package com.xulinhao.service.impl;
/**
 * @author xulinhao
 * @create 2021-05-27 22:19
 */

import com.xulinhao.dao.UserDao;
import com.xulinhao.dao.impl.UserDaoImpl;
import com.xulinhao.service.UserService;
import com.xulinhao.pojo.User;

/**
 * @Author xlh
 * @packagename: com.xulinhao.dao.impl
 * @classname: UserServiceImpl
 * @Description:
 * @Date 2021/5/27
 */
public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();

    @Override
    public void registUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        if (userDao.queryUserByUsername(username) == null) {
            //等于null,说明没查到,没查到表示可用
            return false;
        }
        return true;
    }
}
